package service;

import dao.PhotographerDao;
import entity.*;

import org.springframework.beans.factory.annotation.Autowired;
import relationEntity.OrderTheme;
import relationEntity.OrderUser;
import relationEntity.PhotoTheme;
import util.Page;

import java.util.List;

/**
 * Created by Administrator on 2017/2/9 0009.
 */
public class PhotographerService {
    @Autowired
    private PhotographerDao photographerDao;

    public PhotographerDao getPhotographerDao() {
        return photographerDao;
    }

    public void setPhotographerDao(PhotographerDao photographerDao) {
        this.photographerDao = photographerDao;
    }

    public List<Photographer> findPhotographerList(){
        return photographerDao.findPhotographerList();
    }

    public void saveTheme(Theme theme){
        photographerDao.saveTheme(theme);
    }
    
    public void savePhotographer(Photographer photographer){
    	photographerDao.savePhotographer(photographer);
    }

    public List<PhotoTheme> findPhotoTheme(){
        return photographerDao.findPhotoTheme();
    }

    public Theme findThemeById(int id){
        return photographerDao.findThemeById(id);
    }
    
    public void deleteThemeById(int id){
        photographerDao.deleteThemeById(id);
    }
    
    public void updateTheme(Theme theme){
        photographerDao.updateTheme(theme);
    }

    public List<PhotoTheme> findPhotoThemeById(int id){
        return photographerDao.findPhotoThemeById(id);
    }
    
    public List<Photoorder> findScheduledHours(String scheduleDate){
        return photographerDao.findScheduledHours(scheduleDate);
    }

    public Photographer findPhotographerById(int id){
        return photographerDao.findPhotographerById(id);
    }

    public List<Evaluate> findEvaluateByPhId(int id){
        return photographerDao.findEvaluateByPhId(id);
    }

    public void addPhotoorder(Photoorder photoorder){
        photographerDao.addPhotoorder(photoorder);
    }

    public void updatePhotoorder(String orderCode,int photoorderId){
        photographerDao.updatePhotoorder(orderCode,photoorderId);
    }

    public List<OrderTheme> findOrderThemeByUserId(int id){
        return photographerDao.findOrderThemeByUserId(id);
    }

    public OrderTheme findOrderThemeById(int id){
        return photographerDao.findOrderThemeById(id);
    }

    public List<OrderTheme> findOrderThemeByUserID(int id){
        return photographerDao.findOrderThemeByUserID(id);
    }

    public void addEvaluate(Evaluate evaluate){
        photographerDao.addEvaluate(evaluate);
    }

    public void addAppreciate(Appreciate appreciate){
        photographerDao.addAppreciate(appreciate);
    }

    public List<Appreciate> findAppreciateList(int themeId){
        return photographerDao.findAppreciateList(themeId);
    }
    
    public List<Appreciate> findAppreciateList(int themeId,int userId){
        return photographerDao.findAppreciateList(themeId,userId);
    }
    public List<Appreciate> findAppreciate(int themeId){
        return photographerDao.findAppreciate(themeId);
    }
    public void deleteAppreciate(int themeId,int userId){
        photographerDao.deleteAppreciate(themeId,userId);
    }
    
    public void addAppreciate(int themeId,int userId){
        photographerDao.addAppreciate(themeId,userId);
    }

    public void updatePHOrderStatus(int orderId,String orderStatus,String cloudAddress,String extractedCode){
        photographerDao.updatePHOrderStatus(orderId, orderStatus,cloudAddress,extractedCode);
    }
    
    public void updatePhotographer(Photographer photographer){
        photographerDao.updatePhotographer(photographer);
    }
    
    public void updatePHOrder(int orderId){
        photographerDao.updatePHOrder(orderId);
    }

    public List<Photoorder> findAppointment(String startDate,String endDate){
        return photographerDao.findAppointment(startDate,endDate);
    }



    /**
     * 分页查询
     * @param currentPage 当前页号：现在显示的页数
     * @param pageSize 每页显示的记录条数
     * @return 封闭了分页信息(包括记录集list)的Bean
     * */
    public Page photoorderList(int currentPage,String orderCode, int pageSize){
        Page page = new Page();
        //总记录数
        int allRow = photographerDao.getPhotoOrderAllRowCount(orderCode);
        //当前页开始记录
        int offset = page.countOffset(currentPage,pageSize);
        //分页查询结果集
        List<OrderUser> list = photographerDao.photoorderList(offset,orderCode,pageSize);
        page.setPageNo(currentPage);
        page.setPageSize(pageSize);
        page.setTotalRecords(allRow);
        page.setList(list);
        return page;
    }

    public void addSample(Sample sample){
        photographerDao.addSample(sample);
    }

    public void updatePhotoOrder(int orderId){
        photographerDao.updatePhotoOrder(orderId);
    }

    public void updateSamplOrder(int orderId){
        photographerDao.updateSamplOrder(orderId);
    }
    public List<OrderTheme> findOrderByStatus(int id){
        return photographerDao.findOrderByStatus(id);
    }
    
    public List<OrderTheme> findOrderByStatus(int id,String status){
        return photographerDao.findOrderByStatus(id,status);
    }

    public List<Sample> findSampleList(int themeId,int userId,int orderId){
        return photographerDao.findSampleList(themeId,userId,orderId);
    }

    public List<Sample> findSampleByids(String ids){
        return photographerDao.findSampleByids(ids);
    }
    
    public void updateSampleByids(String ids){
        photographerDao.updateSampleByids(ids);
    }

    public List<Sample> findSampleNotByIds(int themeId,int userId,String ids){
        return photographerDao.findSampleNotByIds(themeId,userId,ids);
    }

    public void addSelectPhoto(SelectPhoto selectPhoto){
        photographerDao.addSelectPhoto(selectPhoto);
    }

 /*   public List<OrderUser> findOrderByStatus(){
        return photographerDao.findOrderByStatus();
    }*/
    /**
     * 分页查询
     * @param currentPage 当前页号：现在显示的页数
     * @param pageSize 每页显示的记录条数
     * @return 封闭了分页信息(包括记录集list)的Bean
     * */
    public Page findOrderByStatus(int currentPage,String orderCode,int pageSize){
        Page page = new Page();
        //总记录数
        int allRow = photographerDao.findOrderByStatusAllRowCount(orderCode);
        //当前页开始记录
        int offset = page.countOffset(currentPage,pageSize);
        //分页查询结果集
        List<OrderUser> list = photographerDao.findOrderByStatus(offset,orderCode,pageSize);
        page.setPageNo(currentPage);
        page.setPageSize(pageSize);
        page.setTotalRecords(allRow);
        page.setList(list);
        return page;
    }

    public List<SelectPhoto> findSelectPhotoByOrderId(int orderId){
        return photographerDao.findSelectPhotoByOrderId(orderId);
    }

    public List<Sample> findSampleByIdList(String ids){
        return photographerDao.findSampleByIdList(ids);
    }

    public void updateOrder(String orderCode){
        photographerDao.updateOrder(orderCode);
    }

	public List<Photographer> selPhotographer() {
		return photographerDao.selPhotographer();
	}

	public List<String> selPotOr(int id) {
		return photographerDao.selPotOr(id);
	}

	public void addSchedule(String id, String schedleDate) {
		photographerDao.addSchedule(id,schedleDate);
	}

	public List<String> selPotCl(int id) {
		return photographerDao.selPotCl(id);
	}

	public List<Integer> selLi(String id, String schedleDate) {
		// TODO Auto-generated method stub
		return photographerDao.selLi(id,schedleDate);
	}

	public void delSchedule(String id, String schedleDate) {
		photographerDao.delSchedule(id,schedleDate);
	}
}
